<div class="giveHeight"> 
    <table class="responsive dynamicTable display table table-bordered dataTable">
        <thead>        
            <tr>
{# sorting of properties based on query components #}
                    {{ knp_pagination_sortable(pagination, 'N° Reglement', 'r.reference') }}
                                {{ knp_pagination_sortable(pagination, 'Raison Social', 'r.client') }}
                    <th>Date</th>
                    <th>Heure</th>
                    <th>Utilisateur</th>
                    <th>Montant TTc</th>
                    <th>Action</th>
                </tr>
            </thead>

{# table body #}
{% for reglement in pagination %}
            <tr {% if loop.index is odd %}class="color"{% endif %}>
                <td style="width:10%;text-align: center">{{ reglement.reference }}</td>
                <td style="width:13%">{{ reglement.client }}</td>
                <td style="width:6%">{{ reglement.date|date('d/m/Y') }} </td>
                <td style="width:4%"> {{ reglement.getTime }}</td>
                <td>{{reglement.user.nom}} {{reglement.user.prenom}}</td>
                <td style="width:8%">{{ reglement.montantTtc|number_format(3) }}</td>
               
                <td class="center ">
                    <div class="controls center">
                        <a class="tip" href="javascript:showReglement('{{reglement.id}}')" title="Visualiser">
                            <span class="icon12 icon-eye-open"></span>
                        </a>
                        {% if is_granted('ROLE_SUPER_ADMIN') and reglement.canModif %}
                        <a style="padding-left:5%"class="tip" href="javascript:editReglement('{{reglement.id}}')" title="Modifier">
                            <span class="icon12 icon-pencil"></span>
                        </a>
                       {% endif %}     
                        <a  style="padding-left:5%;padding-right: 5%" class="tip" href="javascript:imprimerReglement('{{reglement.id}}')" title="Imprimer">
                            <span class="icon12 icon-print"></span>
                        </a>
                       
                            
                            {% if is_granted('ROLE_SUPER_ADMIN') and reglement.canModif==true %}
                        <a class="tip" href="javascript:removeReglement('{{reglement.id}}')" title="Supprimer">
                            <span class="icon12 icomoon-icon-remove"></span>
                        </a>
                            {% endif %}
                    </div>
                </td>
            </tr>
{% endfor %}
        </table>
    </div>
    <div id="DataTables_Table_0_info" class="dataTables_info">Affichage de {{ (pagination.getCurrentPageNumber -1)*pagination.getItemNumberPerPage + 1}} à {{ (pagination.getCurrentPageNumber -1)*pagination.getItemNumberPerPage + pagination.getItemNumberPerPage}} de {{ pagination.getTotalItemCount }} Reglements</div>
{# display navigation #}
    <div id="DataTables_Table_0_paginate" class="dataTables_paginate paging_full_numbers">
    {{ knp_pagination_render(pagination) }}
            </div>
        <script>
                    function showReglement(id) {
                        lf = remplirlf()
                        $.ajax({
                            url: '{{path('gds_vente_reglement_show')}}',
                            data: 'id=' + id,
                            success: function(data) {
                                $('#div_liste_reglement').html(data)
                            }
                        })
                    }
                    function editReglement(id) {
                        lf = remplirlf()
                        $.ajax({
                            url: '{{path('gds_vente_reglement_edit')}}',
                            data: 'id=' + id,
                            success: function(data) {
                                $('#div_liste_reglement').html(data)
                            }
                        })
                    }
                    function imprimerReglement(id) {

                    }
                    function remplirlf() {
                        var liste_f = new Array()
                        liste_f[0] = $('#filtre_numero').val()
                        liste_f[1] = $('#client').val()
                        liste_f[2] = date1
                        liste_f[3] = date2
                        liste_f[4] = heure1
                        liste_f[5] = heure2
                        liste_f[6] = $('#filtre_ref_b').val()
                        liste_f[7] = $('#filtre_ref_f').val()
                        liste_f[8] = $('#filtre_ttc1').val()
                        liste_f[9] = $('#filtre_ttc2').val()
                        liste_f[10] = $('#departement').val()
                        return liste_f
                    }

             {% if is_granted('ROLE_SUPER_ADMIN') %}
                    function removeReglement(id) {
                        $.msgBox({
                            title: "Suppression Reglement",
                            content: "Voulez-vous placer le reglement dans la corbeille ?",
                            type: "confirm",
                            buttons: [{value: "OUI"}, {value: "NON"}, {value: "Annuler"}],
                            success: function(result) {
                                if (result == "OUI") {
                                    $.ajax({
                                        url: '{{path('gds_vente_reglement_delete')}}',
                                        data: 'id=' + id,
                                        success: function(data) {
                                            $.msgBox({
                                                title: "Reglement",
                                                content: "Reglement placé dans la corbeille",
                                                type: "info",
                                                buttons: [{value: "OK"}],
                                                success: function(result) {
                                                    $('#filtre_numero').keyup()
                                                }
                                            })
                                        },
                                        error: function(data) {
                                            alert('erreur lors de la supression!')
                                        }
                                    })
                                }
                            }
                        });

                    }
            {% endif %}
            </script>{# empty Twig template #}
